package cn.ismartv.log.interceptor.sample;

import android.test.AndroidTestCase;
import android.util.Log;

import java.io.IOException;

import cn.ismartv.log.interceptor.HttpLoggingInterceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by huaijie on 1/7/16.
 */
public class LogTest extends AndroidTestCase {
    private static final String TAG = "LogTest";

    public void testLog() {
//        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
//            @Override
//            public void log(String message) {
//                Timber.tag("hello").e(message);
//            }
//        });

        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();

        Request request = new Request.Builder().url("http://lily.tvxio.com/iplookup").build();
        try {
            Response response = client.newCall(request).execute();
            client.newCall(request).execute();
            Log.d(TAG, "result is : " + response.body().string());

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
